//
//  Reward.cpp
//  ballvsblock
//
//  Created by 宋志京 on 2017/6/15.
//
//

#include "Reward.h"
USING_NS_CC;
bool Reward::init(){
    if (!Node::init()){
        return false;
    }
    reward = Sprite::create("ball.png");
    reward->setPosition(Vec2::ZERO);
    addChild(reward);
    
    countLabel = Label::createWithTTF("1", "fonts/Marker Felt.ttf", 45);
    countLabel->setPosition(Vec2::ZERO);
    addChild(countLabel);
    
    return true;
}

void Reward::setNum(int n){
    count=n;
    __String *countStr=__String::createWithFormat("%d",n);
    countLabel->setString(countStr->getCString());
    
    //change color here!
    reward->setColor(Color3B(200, 200, 0));
}

void Reward::hit(){
    //removeFromParent();
	runAction(Sequence::create(DelayTime::create(0), CallFunc::create(CC_CALLBACK_0(Node::removeFromParent, this)), NULL));
}

float Reward::getRewardWidth(){
    return reward->getContentSize().width*2;
}
